package com.shenmazong.servertalkadmin.controller;

import com.shenmazong.servertalkadmin.service.TbStudentService;
import com.shenmazong.utils.ResponseResult;
import io.swagger.annotations.*;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api(tags = "接口-学生管理微服务")
public class StudentController {

    @Autowired
    private TbStudentService studentService;
    /**
     * @Description:
     * @Author: 王大勇
     * TODO addStudentUser 增加学生用户
     * @Date: 2020/9/9 10:34
     * @return: java.lang.com.wdy.utils.ResponseResult
     **/
    @PostMapping("/addStudentUser")
    @ApiOperation(value = "添加学生", notes = "学生添加信息")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userName", value = "登录账号", dataType = "String", required=true),
            @ApiImplicitParam(name="nickName", value = "学生姓名", dataType = "String", required=true),
            @ApiImplicitParam(name="mobile", value = "学生电话", dataType = "String", required=true),
            @ApiImplicitParam(name="fee", value = "学生费用余额", dataType = "Long", required=true, example = "0")
    })
    public ResponseResult addStudentUser(@RequestParam("userName") String userName,
                                         @RequestParam("nickName") String nickName,
                                         @RequestParam("mobile") String mobile,
                                         @RequestParam("fee") Long fee){
        return studentService.addStudentUser(userName, nickName, mobile, fee);
    }
    /**
     * @Description:
     * @Author: 王大勇
     * TODO delStudentUser 删除学生
     * @Date: 2020/9/9 10:34
     * @return: java.lang.ResponseResult
     **/
    @PostMapping("/delStudentUser")
    @ApiOperation(value = "删除学生", notes = "删除学生信息")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="studentId", value = "学生id", dataType = "Integer", required=true)
    })
    public ResponseResult delStudentUser(@RequestParam("studentId") Integer studentId){
        return studentService.delStudentUser(studentId);
    }
    /**
     * @Description:
     * @Author: 王大勇
     * @Date: 2020/9/9 10:37
     * TODO setStudentPass 修改学生密码
     * @return: java.lang.ResponseResult
     **/
    @PostMapping("/setStudentPass")
    @ApiOperation(value = "修改学生密码", notes = "修改学生密码")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="studentId", value = "学生id", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="studentPass", value = "新密码", dataType = "String", required=true)
    })
    public ResponseResult setStudentPass(@RequestParam("studentId") Integer studentId,
                                         @RequestParam("studentPass") String studentPass){
        return studentService.setStudentPass(studentId,studentPass);
    }
    /**
     * @Description:
     * @Author: 王大勇
     * @Date: 2020/9/9 10:38
     * TODO doStudentLogin 学生登陆
     * @return: java.lang.ResponseResult
     **/
    @PostMapping("/doStudentLogin")
    @ApiOperation(value = "学生登陆", notes = "学生登陆")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="studentName", value = "学生姓名", dataType = "String", required=true),
            @ApiImplicitParam(name="studentPass", value = "密码", dataType = "String", required=true)
    })
    public ResponseResult doStudentLogin(@RequestParam("studentName") String studentName,
                                         @RequestParam("studentPass") String studentPass){
        return studentService.doStudentLogin(studentName,studentPass);
    }
    /**
     * @Description:
     * @Author: 王大勇
     * @Date: 2020/9/9 10:38
     * TODO setStudentInfo 修改学生信息
     * @return: java.lang.ResponseResult
     **/
    @PostMapping("/setStudentInfo")
    @ApiOperation(value = "修改学生信息", notes = "修改学生信息")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="nickName", value = "学生姓名", dataType = "String", required=true),
            @ApiImplicitParam(name="mobile", value = "手机号", dataType = "String", required=true),
            @ApiImplicitParam(name="fee", value = "费用余额", dataType = "Long", required=true, example = "0")
    })
    public ResponseResult setStudentInfo(@RequestParam("userId") Integer userId,
                                         @RequestParam("nickName") String nickName,
                                         @RequestParam("mobile") String mobile,
                                         @RequestParam("fee") Long fee){
        return studentService.setStudentInfo(userId, nickName, mobile, fee);
    }

    /**
     * @Description:查询学生信息
     * @Author: 王大勇
     * @Date: 2020/9/11 13:47
     * @param studentId:
     * TODO getStudentInfo 查询学生信息
     * @return: com.wdy.utils.ResponseResult
     **/
    @PostMapping("/getStudentInfo")
    @ApiOperation(value = "查询学生信息", notes = "查询学生信息")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "int", required=true, example = "0")
    })
    public ResponseResult getStudentInfo(@RequestParam("userId") Integer studentId){
        return studentService.getStudentInfo(studentId);
    }

    /**
     * @Description:查询所有学生信息
     * @Author: 王大勇
     * @Date: 2020/9/11 13:48
     * TODO getStudentInfo 查询所有学生信息
     * @return: com.wdy.utils.ResponseResult
     **/
    @ApiOperation(value = "查询所有学生信息", notes = "查询所有学生信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="pageCurrent", value = "当前页", dataType = "int", required=true, example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页记录数", dataType = "int", required=true, example = "0")
    })
    @PostMapping("/getStudentByPage")
    public ResponseResult getStudentByPage(Integer pageCurrent, Integer pageSize){
        return studentService.getStudentByPage(pageCurrent, pageSize);
    }
}
